#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class Solution
{
public:
    int removeCoveredIntervals(vector<vector<int>> &intervals)
    {
        sort(intervals.begin(), intervals.end(), [](const vector<int> &o1, const vector<int> &o2)
             { return o1[0] == o2[0] ? o2[1] < o1[1] : o1[0] < o2[0]; });
        int t = 0;
        int right = 0, next_right = 0;
        for (auto cur : intervals)
        {
            next_right = cur[1];
            if (right < next_right)
            {
                t++;
                right = next_right;
            }
        }
        return t;
    }
};